﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace UIFramework
{
    public class UIDepthItem_Particle : UIDepthItem<ParticleSystem>
    {
        [SerializeField] protected Renderer _renderer;
        [SerializeField] protected bool _hasRenderer;

        public override void Init(string sortingLayer, ParticleSystem component)
        {
            base.Init(sortingLayer, component);
            _renderer = component.GetComponent<Renderer>();
            _hasRenderer = _renderer != null;
            if (_hasRenderer)
            {
                _renderer.sortingLayerName = _sortingLayerName;
                _originalOrder = _renderer.sortingOrder;
            }
        }

        public override void ChangeDepth(int depthDelta)
        {
            if (_hasRenderer)
            {
                _renderer.sortingOrder = _originalOrder + depthDelta;
            }
        }
    }
}
